package dto

import (
	"tuowei.com/app/api/models"
	"tuowei.com/common/dto"
	common "tuowei.com/common/models"
)

type SysShoppingCartGetPageReq struct {
	dto.Pagination `search:"-"`
	BuyerId        int `json:"buyer_id" search:"type:exact;column:buyer_id;table:sys_shopping_cart" comment:"买家id"` // 买家id
}

func (m *SysShoppingCartGetPageReq) GetNeedSearch() interface{} {
	return *m
}

type SysShoppingCartGetReq struct {
	Id int `json:"id"`
}

func (m *SysShoppingCartGetReq) GetNeedSearch() interface{} {
	return *m
}
func (s *SysShoppingCartGetReq) GetId() interface{} {
	return s.Id
}

type SysLbtReq struct {
	LbtType  string `json:"lbt_type" search:"type:exact;column:lbt_type;table:sys_consult_lbt" comment:"图类型"` // 买家id
	Province string `form:"province" json:"province" search:"type:contains;column:province;table:sys_consult_lbt" comment:"适用地区"`
}

func (m *SysLbtReq) GetNeedSearch() interface{} {
	return *m
}

type SysShoppingCartInsertReq struct {
	BuyerId int `comment:"买家id" json:"buyer_id"` //买家id
	Num     int `json:"num" comment:"数量"`        // 数量
	//商品类型OnlineOrder，MaterialOrder
	OrderType        string `json:"order_type" form:"order_type"`
	MaterialOnlineId int    `comment:"资料或者在线课程id" json:"material_online_id"`
	common.ControlBy
}

func (s *SysShoppingCartInsertReq) Generate(model *models.SysShoppingCart, name, subject, introduction, courseType, cover string, price float64) {
	//model.CourseId = s.CourseId
	model.BuyerId = s.BuyerId
	model.Name = name
	model.Subject = subject
	model.Introduction = introduction
	model.OrderType = courseType
	model.Num = s.Num
	model.MaterialOnlineId = s.MaterialOnlineId
	model.Cover = cover
	model.Price = price
}

func (s *SysShoppingCartInsertReq) GetId() interface{} {
	return s.BuyerId
}

type SysShoppingCartUpdateReq struct {
	Id  int `json:"id" comment:"id"`  // id
	Num int `json:"num" comment:"数量"` // 数量
	common.ControlBy
}

func (s *SysShoppingCartUpdateReq) Generate(model *models.SysShoppingCart) {
	if s.Id != 0 {
		model.Id = s.Id
	}
	if s.Num != 0 {
		model.Num = s.Num
	}

	model.CreateBy = s.CreateBy
}

func (s *SysShoppingCartUpdateReq) GetId() interface{} {
	return s.Id
}

type SysShoppingCartDeleteReq struct {
	Id  int   `json:"id"`
	Ids []int `json:"ids"`
}

func (s *SysShoppingCartDeleteReq) GetId() interface{} {
	return s.Id
}
